package spring.yongongsystem.controller.worker;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import spring.yongongsystem.POJO.dto.WorkerDTO;
import spring.yongongsystem.result.Result;
import spring.yongongsystem.service.WorkerService;

@RestController("workerGroupController")
@RequestMapping("/worker/group")
@Api(tags = "用工小组相关接口")
@Slf4j
public class GroupController {

    @Autowired
    private WorkerService workerService;

    /**
     * 加入小组
     * @param id
     * @return
     */
    @PostMapping
    @ApiOperation("加入小组")
    public Result saveGroup(Long id,Long groupId){
        log.info("{} 加入小组：{}", id, groupId);
        workerService.saveGroup(id, groupId);
        return Result.success();
    }

    /**
     * 退出小组
     * @param id
     * @return
     */
    @PostMapping("/back")
    @ApiOperation("退出小组")
    public Result backGroup(Long id){
        log.info("{} 退出小组",id);
        workerService.backGroup(id);
        return Result.success();
    }
}
